-- get the addon namespace
local addon, ns = ...

-- get the config values
local cfg = ns.cfg

-- get the library
local lib = ns.lib
lib.classes["WARRIOR"] = {}
local t,s
local PW_TH = 120 - 10
local AVIN = -1

lib.classes["WARRIOR"][2] = function ()

	cfg.talentname = "KB"
	
	lib.AddSpell("BT",{23881}) -- Bloodthirst
	lib.AddSpell("RB",{85288}) -- Raging Blow	
	lib.AddSpell("BR",{18499}) -- Berserker Rage
	lib.AddSpell("CS",{86346}) -- Colossus Smash
	lib.AddSpell("slam",{1464}) -- Slam
	lib.AddSpell("EX",{5308}) -- Execute
	lib.AddSpell("BS",{6673}) -- Battle Shout
	lib.AddSpell("DW",{12292}) -- Death Wish
	lib.AddSpell("HS",{78}) -- Heroic Strike
	lib.AddSpell("SH",{107570}) -- 
	lib.AddSpell("DS",{118000})
	lib.AddSpell("SS",{100130})
	lib.AddSpell("VR",{103840})

	
	lib.AddSpell("IR",{1134}) -- Inner Rage
	lib.AddSpell("CL",{845}) -- Cleave
	lib.AddSpell("WW",{1680}) -- Whirlwind
	

	lib.AddAura("B_RB",131116,"buff","player") -- Bloodsurge
	lib.AddAura("B_BS",46916,"buff","player") -- Bloodsurge
	lib.AddAura("B_CS",86346,"debuff","target") -- Bloodsurge
	--lib.AddAura("B_DC",85730,"buff","player") -- Bloodsurge
	--lib.AddAura("Executioner",90806,"buff","player") -- Executioner
	lib.AddAura("Trance",12964,"buff","player") -- Battle Trance
	lib.AddAura("Incite",86627,"buff","player") -- Incite
	lib.AddAura("B_MC",12950,"buff","player") -- Incite
	lib.AddAura("B_SD",29725,"buff","player") -- Incite
	
	lib.AddAuras("Enrage",{14202,12292,18499,49016},"buff","player") -- Enrage
	
	
	cfg.plistdps = {}
	-------
	table.insert(cfg.plistdps,"HS_EX")
	-------
	--[[
	table.insert(cfg.plistdps,"SH_EX_CS")
	table.insert(cfg.plistdps,"BT_EX_CS")
	table.insert(cfg.plistdps,"RB_EX_CS")
	table.insert(cfg.plistdps,"DS_EX_CS")
	table.insert(cfg.plistdps,"HT_EX_CS")
	table.insert(cfg.plistdps,"BS_EX_CS")
	--]]
	-------
	table.insert(cfg.plistdps,"EX_EX_CS")
	table.insert(cfg.plistdps,"BT_EX")
	table.insert(cfg.plistdps,"CS_EX")
	table.insert(cfg.plistdps,"EX_EX") -- *
	table.insert(cfg.plistdps,"DS_EX")
	table.insert(cfg.plistdps,"SH_EX")
	table.insert(cfg.plistdps,"RB_EX")
	table.insert(cfg.plistdps,"BS_EX") -- *
	table.insert(cfg.plistdps,"HT_EX")
	-------
	table.insert(cfg.plistdps,"HS")
	table.insert(cfg.plistdps,"BT")
	table.insert(cfg.plistdps,"CS")
	table.insert(cfg.plistdps,"SH")
	table.insert(cfg.plistdps,"DS")
	table.insert(cfg.plistdps,"RB")
	table.insert(cfg.plistdps,"SS")
	table.insert(cfg.plistdps,"BS")
	table.insert(cfg.plistdps,"VR")
	table.insert(cfg.plistdps,"HT")
	table.insert(cfg.plistdps,"SS_NOBS")
	
	table.insert(cfg.plistdps,"end")
	
	cfg.plistaoe = {}
	table.insert(cfg.plistaoe,"CL_A")
	table.insert(cfg.plistaoe,"BT_A")
	table.insert(cfg.plistaoe,"DS_A")
	table.insert(cfg.plistaoe,"RB_A")
	table.insert(cfg.plistaoe,"CS_A")
	table.insert(cfg.plistaoe,"WW_A")
	table.insert(cfg.plistaoe,"CS_FORCE_A")
	table.insert(cfg.plistaoe,"SS_A")
	table.insert(cfg.plistaoe,"BS_A")
	table.insert(cfg.plistaoe,"end")
	
	cfg.plist=cfg.plistdps

	cfg.case = {}
	cfg.case = {
	
		["BT"] = function() 
			if cfg.health <= 20 then
				return nil
			end
			if lib.GetAuraNum("B_RB") < 2 and lib.GetSpellCD('BT',true) <= 2 then
				return lib.SimpleCDCheck("BT",0,true)
				--[[
				if lib.SimpleCDCheck("BT") then
					AVIN = lib.GetAuraNum("B_RB")
					if lib.GetSpellCD("SH") <= lib.GetSpellCD(cfg.gcd) + AVIN * 1.5 + 0.1 then
						AVIN = AVIN + 1
					end
					if lib.GetSpellCD("DS") <= lib.GetSpellCD(cfg.gcd) + AVIN * 1.5 + 0.1 then
						AVIN = AVIN + 1
					end
					return true
				end
				]]
			end
			return nil
		end,
		
		["CS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			return lib.SimpleCDCheck("CS")
		end,
		
		["SH"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if lib.GetSpellCD("CS") - lib.GetSpellCD(cfg.gcd,true) >= 6 and not(lib.GetAuraNum("B_RB") == 2 and lib.GetSpellCD("BT") <= lib.GetSpellCD(cfg.gcd,true)) then
				return lib.SimpleCDCheck("SH")
			end
			return nil
		end,
		
		["RB"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if not (lib.GetAuraNum("B_RB") < 2 and lib.GetAura({"B_CS"}) <= 0) or (lib.GetAura({"B_RB"}) <= 4 and lib.GetAura({"B_RB"}) >= lib.GetSpellCD(cfg.gcd,true)) then
				return lib.SimpleCDCheck("RB") ------------------------ after 81
			end
			return nil
		end,
		
		["DS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if lib.GetAura({"B_CS"}) <= 0 then
				return lib.SimpleCDCheck("DS")
			end
			return nil
		end,
		
		["BS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if lib.GetAura({"B_CS"}) <= 0 then
				return lib.SimpleCDCheck("BS")
			end
			return nil
		end,
		
		["HS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if cfg.power >= PW_TH or (lib.GetAura({"B_CS"}) > 0 and cfg.power > 60) then
				return lib.SimpleCDCheck("HS")
			end
			return nil
		end,
		
		["SS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			if lib.GetAura({"B_BS"}) > 0 and AVIN < 2 then
				if lib.GetAuraNum("B_BS")  <= lib.GetSpellCD("BT") - lib.GetSpellCD(cfg.gcd,true) + 0.1 then
					return lib.SimpleCDCheck("SS")
				else 
				
				end
			end
			return nil
		end,
		
		["SS_NOBS"] = function()
			if cfg.health <= 20 then
				return nil
			end
			return lib.SimpleCDCheck("SS")
		end,
		---------------------
		
		["BT_EX"] = function() 
			if cfg.health <= 20 and lib.GetAuraNum("B_RB") < 2 and lib.GetSpellCD('BT',true) <= 2 then
				return lib.SimpleCDCheck("BT",0,true)
			end
			return nil
		end,
		
		["CS_EX"] = function()
			if cfg.health <= 20 then
				return lib.SimpleCDCheck("CS")
			end
			return nil
		end,
				
		["RB_EX"] = function()
			if cfg.health <= 20 and cfg.power < PW_TH then
				return lib.SimpleCDCheck("RB")
			end
			return nil
		end,
		
		["SH_EX"] = function()
			if cfg.health <= 20 and cfg.power < PW_TH then
				return lib.SimpleCDCheck("SH")
			end
			return nil
		end,
		
		["DS_EX"] = function()
			if cfg.health <= 20 then
				return lib.SimpleCDCheck("DS")
			end
			return nil
		end,
		
		["EX_EX"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) <= 0 then
				if cfg.power >= 90 then
					return lib.SimpleCDCheck("EX")
				end
			end
			return nil
		end,
		
		["BS_EX"] = function()
			if cfg.health <= 20 then
				return lib.SimpleCDCheck("BS")
			end
			return nil
		end,
		
		["HT_EX"] = function()
			if cfg.health <= 20 then
				return lib.SimpleCDCheck("HT")
			end
			return nil
		end,
		
		["HS_EX"] = function()
			if cfg.health <= 20 and (cfg.power >= PW_TH or (lib.GetAura({"B_DC"}) > 0 and cfg.power > 20)) then
				return lib.SimpleCDCheck("HS")
			end
			return nil
		end,
		
		["EX_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 then
				return lib.SimpleCDCheck("EX")
			end
			return nil
		end,
		--------------------------
		--[[
		["SH_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 then
				return lib.SimpleCDCheck("SH")
			end
			return nil
		end,
		
		
		["BT_EX_CS"] = function() 
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 and lib.GetAuraNum("B_RB") < 2 then
				return lib.SimpleCDCheck("BT")
			end
			return nil
		end,
				
		["RB_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 then
				return lib.SimpleCDCheck("RB")
			end
			return nil
		end,
		
		
		["DS_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 then
				return lib.SimpleCDCheck("DS")
			end
			return nil
		end,
		
		["HT_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) <= 0 then
				return lib.SimpleCDCheck("HT")
			end
			return nil
		end,
		
		["BS_EX_CS"] = function()
			if cfg.health <= 20 and lib.GetAura({"B_CS"}) > 0 then
				return lib.SimpleCDCheck("BS")
			end
			return nil
		end,
		]]
		-------
		
		["BT_A"] = function()
			if lib.GetAuraNum("B_RB") < 2 and cfg.power < PW_TH then
				return lib.SimpleCDCheck("BT")
			end
			return nil
		end,
		
		["DS_A"] = function()
			return lib.SimpleCDCheck("DS")
		end,
		
		["WW_A"] = function()
			if lib.GetAuraNum("B_MC") < 3 then
				return lib.SimpleCDCheck("WW")
			end
			return nil
		end,
		
		["CS_A"] = function()
			if lib.GetAuraNum("B_RB") < 1 then
				return lib.SimpleCDCheck("CS")
			end
			return nil
		end,
		
		["RB_A"] = function()
			if lib.GetAuraNum("B_MC") == 3 then
				return lib.SimpleCDCheck("RB")
			end
			return nil
		end,
		
		["CS_FORCE_A"] = function()
			return lib.SimpleCDCheck("CS")
		end,
		
		
		["CL_A"] = function()
			if cfg.power >= PW_TH then
				return lib.SimpleCDCheck("CL")
			end
			return nil
		end,
		
		["SS_A"] = function()
			if lib.GetAura({"B_BS"}) > 0 then
				return lib.SimpleCDCheck("SS")
			end
			return nil
		end,
		
		["BS_A"] = function()
			return lib.SimpleCDCheck("BS")
		end,
		
		["WW_A_Default"] = function()
			return lib.SimpleCDCheck("WW",0,true)
		end,
		
		
	--[[
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"hs_Trance")
	table.insert(cfg.plistdps,"execute_end")
	table.insert(cfg.plistdps,"cs")
	table.insert(cfg.plistdps,"execute_5stack")
	table.insert(cfg.plistdps,"bt")
	table.insert(cfg.plistdps,"Enrage")
	table.insert(cfg.plistdps,"rb")
	table.insert(cfg.plistdps,"slam_bs")
	table.insert(cfg.plistdps,"execute_50rage")
	table.insert(cfg.plistdps,"bs_single")
	table.insert(cfg.plistdps,"end")
	
	cfg.plistaoe = {}
	table.insert(cfg.plistaoe,"ww")
	table.insert(cfg.plistaoe,"ir")
	table.insert(cfg.plistaoe,"cleave")
	table.insert(cfg.plistaoe,"cs")
	table.insert(cfg.plistaoe,"rb_aoe")
	table.insert(cfg.plistaoe,"br")
	table.insert(cfg.plistaoe,"bs")
	table.insert(cfg.plistaoe,"end")

	cfg.plist=cfg.plistdps

	cfg.case = {}
	cfg.case = {
		["execute_end"] = function()
			if cfg.power>=20 then
				return lib.SimpleCDCheck("execute",lib.GetAura({"Executioner"})-1.5)
			end
			return nil
		end,
		["execute_5stack"] = function()
			if cfg.power>=20 and lib.GetAuraNum("Executioner")<5 then
				return lib.SimpleCDCheck("execute")
			end
			return nil
		end,
		["execute_50rage"] = function()
			if cfg.power>=50 then
				return lib.SimpleCDCheck("execute")
			end
			return nil
		end,
		["rb_aoe"] = function()
			if cfg.power >= 70  then
				return lib.SimpleCDCheck("rb")
			end
			return nil
		end,
		["cleave"] = function()
			if cfg.power>=(lib.GetSpellCost("cleave")+lib.GetSpellCost("ww")) then
				return lib.SimpleCDCheck("cleave")
			end
			return nil
		end,
		["slam_bs"] = function ()
			if lib.GetAura({"bs"})>0 then
				return lib.SimpleCDCheck("slam")
			end
			return nil
		end,
		["Enrage"] = function ()
			if cfg.power>15 and lib.GetSpellCD(cfg.gcd,true)>0 then
				return lib.SimpleCDCheck("br",lib.GetAuras("Enrage"))
			end
			return nil
		end,
		["hs_Trance"] = function ()
			if (lib.GetAura({"Trance"})>0 or cfg.power >= 85) and lib.GetSpellCD(cfg.gcd,true)>0 then
				return lib.SimpleCDCheck("hs")
			end
			return nil
		end,
		["hs"] = function ()
			if cfg.power == 100 then
				return lib.SimpleCDCheck("hs")
			end
			return nil
		end,
		["bs_single"] = function ()
			if cfg.power < 70 then
				return lib.SimpleCDCheck("bs")
			end
			return nil
		end,
		]]
	}

	cfg.mode = "dps"
	
	lib.onclick = function()
		if cfg.mode == "dps" then
			cfg.mode = "aoe"
			cfg.plist=cfg.plistaoe
			cfg.Update=true
		else
			cfg.mode = "dps"
			cfg.plist=cfg.plistdps
			cfg.Update=true
		end
		
	end
	
	return true
end

lib.classes["WARRIOR"][1] = function ()

	cfg.talentname = "WQ"
	
	lib.AddSpell("cs",{86346}) -- Colossus Smash
	lib.AddSpell("ms",{12294}) -- Mortal Strike
	lib.AddSpell("slam",{1464}) -- Slam
	lib.AddSpell("op",{7384}) -- Overpower
	lib.AddSpell("execute",{5308}) -- Execute
	lib.AddSpell("bs",{6673}) -- Battle Shout
	lib.AddSpell("hs",{78}) -- Heroic Strike
	lib.AddSpell("br",{18499}) -- Berserker Rage
	lib.AddSpell("cleave",{845}) -- Cleave
	lib.AddSpell("ss",{12328}) -- Sweeping Strikes
	lib.AddSpell("bls",{46924}) -- Bladestorm
	lib.AddSpell("vr",{34428}) -- Victory Rush
	lib.AddSpell("Clap",{6343}) -- Thunder Clap
	lib.AddSpell("Berserker",{2458}) -- Berserker 
	lib.AddSpell("Battle",{2457}) -- Battle 
	lib.AddSpell("DS",{118000})
	lib.AddSpell("YX",{12292})
	lib.AddSpell("LM",{1719})
				
	lib.AddAura("cs",86346,"debuff","target") -- Colossus Smash
	lib.AddAura("ToB",60503,"buff","player") -- Taste for Blood
	lib.AddAura("sd",52437,"buff","player") -- Sudden Death
	lib.AddAura("Trance",12964,"buff","player") -- Battle Trance
	lib.AddAura("Incite",86627,"buff","player") -- Incite
	lib.AddAura("Enrage",12880,"buff","player") -- Enrage
	lib.AddAura("WC",57519,"buff","player") -- Wrecking Crew
	lib.AddAura("br",18499,"buff","player") -- Berserker Rage
	lib.AddAura("B_SD",139958,"buff","player") -- Berserker Rage
	
	cfg.plistfulldps = {}
	table.insert(cfg.plistfulldps,"YX")
	table.insert(cfg.plistfulldps,"LM")
	table.insert(cfg.plistfulldps,"hs")
	table.insert(cfg.plistfulldps,"br")
	table.insert(cfg.plistfulldps,"ex_cs")
	table.insert(cfg.plistfulldps,"ms")
	table.insert(cfg.plistfulldps,"DS")
	table.insert(cfg.plistfulldps,"cs_nocs")
	table.insert(cfg.plistfulldps,"execute")
	table.insert(cfg.plistfulldps,"op")
	table.insert(cfg.plistfulldps,"slam")
	table.insert(cfg.plistfulldps,"cs_nocs15")
	table.insert(cfg.plistfulldps,"bs_single")
	table.insert(cfg.plistfulldps,"HT")
	table.insert(cfg.plistfulldps,"end")
		
	cfg.plistdps = {}
	table.insert(cfg.plistdps,"hs")
	table.insert(cfg.plistdps,"br")
	table.insert(cfg.plistdps,"ex_cs")
	table.insert(cfg.plistdps,"ms")
	table.insert(cfg.plistdps,"DS")
	table.insert(cfg.plistdps,"cs_nocs")
	table.insert(cfg.plistdps,"execute")
	table.insert(cfg.plistdps,"op")
	table.insert(cfg.plistdps,"slam")
	table.insert(cfg.plistdps,"cs_nocs15")
	table.insert(cfg.plistdps,"bs_single")
	table.insert(cfg.plistdps,"HT")
	table.insert(cfg.plistdps,"end")
	
	cfg.plistaoe = {}
--	table.insert(cfg.plistaoe,"Stance_Berserker")
	table.insert(cfg.plistaoe,"Stance_Battle_Rend_aoe")
	table.insert(cfg.plistaoe,"Stance_Berserker_aoe")
	table.insert(cfg.plistaoe,"Rend_bns")
	table.insert(cfg.plistaoe,"Clap_bns")
	table.insert(cfg.plistaoe,"br")	
	table.insert(cfg.plistaoe,"bls")
	table.insert(cfg.plistaoe,"ww")
	table.insert(cfg.plistaoe,"cleave")
	table.insert(cfg.plistaoe,"ms_aoe")
--	table.insert(cfg.plistaoe,"ms")
	table.insert(cfg.plistaoe,"execute")
	table.insert(cfg.plistaoe,"bs_single")
	table.insert(cfg.plistaoe,"end")

	cfg.plist=cfg.plistdps
	
	cfg.case = {}
	cfg.case = {
		["YX"] = function()
			if ns.db.cdsonboss and cfg.target ~= 'worldboss' then
				return nil
			end
			if lib.GetSpellCD('cs',true) <= lib.GetSpellCD(cfg.gcd,true) and lib.inrange('ms') then
				return lib.SimpleCDCheck("YX")
			end
			return nil
		end,
		["LM"] = function()
			if ns.db.cdsonboss and cfg.target ~= 'worldboss' then
				return nil
			end
			if lib.GetSpellCD('cs',true) <= lib.GetSpellCD(cfg.gcd,true) and lib.inrange('ms') then
				return lib.SimpleCDCheck("LM")
			end
			return nil
		end,
	
		["execute"] = function()
			if cfg.power>=90 then
				return lib.SimpleCDCheck("execute")
			end
			return nil
		end,
		["br"] = function()
			if cfg.power<=95 and lib.inrange('ms') and lib.GetAura({"Enrage","br"})==0 then
				return lib.SimpleCDCheck("br")
			end
			return nil
		end,
		
		["ex_cs"] = function()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) < 0.5 then
				return nil
			end
			if lib.GetAura({"cs"}) > lib.GetSpellCD(cfg.gcd,true) then
				return lib.SimpleCDCheck("execute")
			end
			return nil
		end,
		["slam"] = function ()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) < 0.5 then
				return nil
			end
			if cfg.power >= 20 then
				return lib.SimpleCDCheck("slam")
			end
			return nil
		end,
		["cs_nocs15"] = function()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) < 0.5 then
				return nil
			end
			return lib.SimpleCDCheck("cs",(lib.GetAura({"cs"})-1.5))
		end,
		["cs_nocs"] = function()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) < 0.5 then
				return nil
			end
			return lib.SimpleCDCheck("cs",lib.GetAura({"cs"}))
		end,
		["op"] = function()
			if cfg.health > 20 then
				return lib.SimpleCDCheck('op');
			elseif cfg.health <= 20 and lib.GetAura({"B_SD"}) > 0 then
				return lib.SimpleCDCheck('op');
			end
			return nil;
		end,
		["hs"] = function ()
			if lib.GetSpellCD(cfg.gcd,true)>0 then
				if cfg.health>20 and cfg.power>70 and lib.GetAura({"cs"}) > lib.GetSpellCD("hs") then
					return lib.SimpleCDCheck("hs")
				end
				if cfg.power>110 then
					return lib.SimpleCDCheck("hs")
				end
			end
			return nil
		end,
		["Stance_Battle_OP"] = function()
			if cfg.shape~="Battle" and cfg.health>20 and lib.GetAura({"ToB"})>0 and cfg.power<=75 and lib.GetSpellCD("ms",true)>1.5 and lib.GetSpellCD("cs",true)>1.5 then
				return lib.SimpleCDCheck("Battle")
			end
			return nil
		end,
		["Stance_Berserker_Execute"] = function()
			if cfg.shape~="Berserker" and cfg.health<=20 and lib.GetAura({"ToB"})==0 and cfg.power<=75 and lib.GetAura({"Rend"})>lib.GetSpellCD("ms",true) then
				return lib.SimpleCDCheck("Berserker")
			end
			return nil
		end,
		["Stance_Berserker_aoe"] = function()
			if cfg.shape~="Berserker" and not cfg.bnt then
				return lib.SimpleCDCheck("Berserker")
			end
			return nil
		end,
		["ms"] = function()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) < 1 then
				return lib.SimpleCDCheck("ms",0,true)
			end
			return nil
		end,
		["ms20"] = function()
			if cfg.health<=20 and (lib.GetAura({"WC"})==0 or lib.GetAura({"Rend"})<3 or cfg.power<=25 or cfg.power>=35)  then
				return lib.SimpleCDCheck("ms")
			end
			return nil
		end,
		["Rend_noRend"] = function()
			if not lib.GetLastSpell({"Rend"}) then
				return lib.SimpleCDCheck("Rend",lib.GetAura({"Rend"}))
			end
			return nil
		end,
		["Rend_bns"] = function()
			if cfg.bnt and not lib.GetLastSpell({"Rend"}) then
				return lib.SimpleCDCheck("Rend",lib.GetAura({"Rend"}))
			end
			return nil
		end,
		["Stance_Berserker"] = function()
			if cfg.shape~="Berserker" and lib.GetAura({"ToB"})==0 and lib.GetAura({"Rend"})>lib.GetSpellCD(cfg.gcd,true) and cfg.power<=75 then
				return lib.SimpleCDCheck("Berserker")
			end
			return nil
		end,
		["Stance_Battle_Rend_aoe"] = function()
			if cfg.shape~="Battle" and lib.GetAura({"Rend"})<=lib.GetSpellCD(cfg.gcd,true) and cfg.bnt then
				return lib.SimpleCDCheck("Battle")
			end
			return nil
		end,
		["Stance_Battle_Rend"] = function()
			if cfg.shape~="Battle" and lib.GetAura({"Rend"})<=lib.GetSpellCD(cfg.gcd,true) then
				return lib.SimpleCDCheck("Battle")
			end
			return nil
		end,
		["Clap_bns"] = function()
			if cfg.bnt and lib.GetAura({"Rend"})>lib.GetSpellCD("Clap",true) then
				return lib.SimpleCDCheck("Clap")
			end
			return nil
		end,
		["ms_aoe"] = function()
			if lib.GetAura({"Calm"})>0 or cfg.power>=(lib.GetSpellCost("ms")+lib.GetSpellCost("ww")+lib.GetSpellCost("cleave")) then
				return lib.SimpleCDCheck("ms")
			end
			return nil
		end,
		["ms_Rend"] = function()
			t = lib.GetAura({"Rend"})
			if t>0 and t<3 then
				return cfg.case["ms"]()
			end
			return nil
		end,
		["cleave"] = function()
			if cfg.power>=(lib.GetSpellCost("cleave")+lib.GetSpellCost("ww")) then
				return lib.SimpleCDCheck("cleave")
			end
			return nil
		end,

		["bs_single"] = function ()
			if cfg.power < 60 and lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) > 0.5 then
				return lib.SimpleCDCheck("bs")
			end
			return nil
		end,

		["HT"] = function()
			if lib.GetSpellCD("ms",true) - lib.GetSpellCD(cfg.gcd,true) > 0.5 then
				return lib.SimpleCDCheck("HT")
			end
			return nil
		end,
	}
	cfg.spells_aoe={"cleave","bls","ww"}
	cfg.spells_single={"hs","ms","op","cs"}
	return true
end


lib.classes["WARRIOR"][3] = function ()

	cfg.talentname = "FZ"

	--lib.AddSpell("Rend",{772}) -- Rend
	lib.AddSpell("ss",{23922}) -- Shield Slam 
	lib.AddSpell("ex",{5308}) -- Shield Slam 
	lib.AddSpell("rv",{6572}) -- Revenge 
	lib.AddSpell("ds",{20243}) -- Devastate 
	lib.AddSpell("Clap",{6343}) -- Thunder Clap
	lib.AddSpell("sw",{46968}) -- Shockwave
	lib.AddSpell("sb",{2565}) -- Shield Block
	lib.AddSpell("sp",{112048}) -- Shield Block
	--lib.AddSpell("cb",{12809}) -- Concussion Blow
	lib.AddSpell("des",{1160}) -- Demoralizing Shout 
	lib.AddSpell("bs",{6673}) -- Battle Shout
	lib.AddSpell("br",{18499}) -- Berserker Rage
	lib.AddSpell("ir",{1134}) -- Inner Rage
	lib.AddSpell("rr",{55694}) -- Inner Rage
	
	lib.AddSpell("vr",{34428}) -- Victory Rush
	lib.AddSpell("hs",{78}) -- Heroic Strike
	lib.AddSpell("cleave",{845}) -- Cleave
	lib.AddSpell("ht",{57755}) -- Heroic Throw
				
	lib.AddAura("Rend",94009,"debuff","target") -- Rend
	lib.AddAura("snb",50227,"buff","player") -- Sword and Board
	lib.AddAura("sb",132404,"buff","player") -- Sword and Board
	lib.AddAura("sp",112048,"buff","player") -- Sword and Board
	lib.AddAura("ths",87096,"buff","player") -- Thunderstruck
	lib.AddAura("Incite",122510,"buff","player") -- Incite

	--lib.AddAuras("Clap",{6343,54404,90315,8042,45477,58180,68055,51693,115767},"debuff","target") -- Thunder Clap
	lib.AddAura("Clap",{115798},"debuff","target") -- Thunder Clap
	
	lib.AddAuras("Demo",{1160,702,99,50256,24423,81130,26017},"debuff","target") -- Demoralizing Shout 
	
	cfg.plistfulldps = {}
	--table.insert(cfg.plistdps,"ht")
	--table.insert(cfg.plistdps,"cb")
	--table.insert(cfg.plistdps,"Clap_bnt")
	table.insert(cfg.plistfulldps,"br")
	table.insert(cfg.plistfulldps,"hs")
	table.insert(cfg.plistfulldps,"ss")
	table.insert(cfg.plistfulldps,"vr")
	table.insert(cfg.plistfulldps,"rv") 
	--table.insert(cfg.plistdps,"Rend_noRend")
	--table.insert(cfg.plistdps,"des_noDemo")
	--table.insert(cfg.plistfulldps,"Clap_noClap")
	--table.insert(cfg.plistdps,"sw_ths")
	table.insert(cfg.plistfulldps,"sb")
	table.insert(cfg.plistfulldps,"ex")
	table.insert(cfg.plistfulldps,"ds")
	table.insert(cfg.plistfulldps,"bs")
	table.insert(cfg.plistfulldps,"end")
	cfg.plistdps = {}
	--table.insert(cfg.plistdps,"ht")
	--table.insert(cfg.plistdps,"cb")
	--table.insert(cfg.plistdps,"Clap_bnt")
	table.insert(cfg.plistdps,"br")
	table.insert(cfg.plistdps,"hs")
	table.insert(cfg.plistdps,"ss")
	table.insert(cfg.plistdps,"vr")
	table.insert(cfg.plistdps,"rv") 
	--table.insert(cfg.plistdps,"Rend_noRend")
	--table.insert(cfg.plistdps,"des_noDemo")
	--table.insert(cfg.plistdps,"Clap_noClap")
	--table.insert(cfg.plistdps,"sw_ths")
	--table.insert(cfg.plistdps,"sb")
	table.insert(cfg.plistdps,"ex")
	table.insert(cfg.plistdps,"ds")
	table.insert(cfg.plistdps,"bs")
	table.insert(cfg.plistdps,"end")

	
	cfg.plistaoe = {}
--	table.insert(cfg.plistaoe,"vr")
	table.insert(cfg.plistaoe,"Rend_noRend")
	table.insert(cfg.plistaoe,"Clap")
	table.insert(cfg.plistaoe,"sw")
	table.insert(cfg.plistaoe,"des_noDemo")
	table.insert(cfg.plistaoe,"sb")
	table.insert(cfg.plistaoe,"rv")
	table.insert(cfg.plistaoe,"ss")
	table.insert(cfg.plistaoe,"cleave")
	table.insert(cfg.plistaoe,"bs")
	table.insert(cfg.plistaoe,"end")

	cfg.plist=cfg.plistdps

	cfg.case = {}
	cfg.case = {
		["sw_ths"] = function()
			if lib.GetAuraNum("ths")==3 then
				return lib.SimpleCDCheck("sw")
			end
			return nil
		end,
		["ex"] = function()
			if cfg.health < 20 and cfg.power >= 65 then
				return lib.SimpleCDCheck("ex")
			end
			return nil
		end,
--[[		["Clap_bnt"] = function()
			if cfg.bnt and lib.GetAura({"Rend"})>lib.GetSpellCD("Clap") then
				return lib.SimpleCDCheck("Clap",lib.GetAura({"Rend"})-4)
			end
			return nil
		end,]]
		["sb"] = function()
			return lib.SimpleCDCheck("sb",lib.GetAura({"sb"}))
		end,
		["sp"] = function()
			return lib.SimpleCDCheck("sp",lib.GetAura({"sp"}))
		end,
		["Clap_noClap"] = function()
			return lib.SimpleCDCheck("Clap",lib.GetAura({"Clap"}))
		end,
		["des_noDemo"] = function()
			return lib.SimpleCDCheck("des",lib.GetAuras("Demo"))
		end,
		["Rend_noRend"] = function()
			return lib.SimpleCDCheck("Rend",lib.GetAura({"Rend"}))
		end,
		["cleave"] = function()
			if cfg.power>65 and lib.GetSpellCD(cfg.gcd,true)>0  then
				return lib.SimpleCDCheck("cleave")
			end
			return nil
		end,
		["hs"] = function ()
			if lib.GetAura({"Incite"})>lib.GetSpellCD("hs") then
				return lib.SimpleCDCheck("hs")
			end
			return nil
		end,
		["bs"] = function ()
			if cfg.power<120 then
				return lib.SimpleCDCheck("bs")
			end
			return nil
		end,
		["br"] = function ()
			if cfg.power<110 and lib.GetSpellCD("rr") >= 28 then
				return lib.SimpleCDCheck("br")
			end
			return nil
		end,
	}
	cfg.spells_aoe={"cleave"}
	cfg.spells_single={"hs"}
	return true
end

lib.classevents["WARRIOR"] = function()
	lib.AddSpell("Sunder",{7386}) -- Sunder
	cfg.gcd="Sunder"
	
	cfg.bnt=0
	--[[
	lib.mytal = function()
		local nameTalent, icon, tier, column, currRank, maxRank= GetTalentInfo(3,3)
		cfg.bnt = currRank>0 and true or nil
	end
	]]
	lib.AddSpell("strike",{88161}) -- Strike
	lib.AddSpell("Charge",{100}) -- Charge
	lib.AddSpell("HT",{57755}) -- Heroic Throw
	
	lib.rangecheck=function()
		if lib.inrange("strike") then
			lib.bdcolor(Heddframe.bd,nil)
		elseif lib.inrange("Charge") then
			lib.bdcolor(Heddframe.bd,{0,1,0,1})
		elseif lib.inrange("ht") then
			lib.bdcolor(Heddframe.bd,{0,0,1,1})
		else
			lib.bdcolor(Heddframe.bd,{1,0,0,1})
		end
	end
	
	cfg.mode = "dps"
	lib.onclick = function()
		if cfg.mode == "dps" then
			cfg.mode = "aoe"
			cfg.plist=cfg.plistaoe
			cfg.Update=true
		else
			cfg.mode = "dps"
			cfg.plist=cfg.plistdps
			cfg.Update=true
		end
		
	end
end